<template>
  <div>
    <Son v-model:show="show" v-model="show"></Son>
    <van-button type="primary" @click="show = true">登录</van-button>

    <!-- 测试全局封装头组件 -->
    <!-- <cp-nav-bar :title="'登录'" :rightText="'注册'" @click-right="clickRight"></cp-nav-bar> -->
    <h1>测试页面</h1>
    <ul>
      <li>{{ store.user }}</li>
      <li>
        <button @click="setUser">修改store数据</button>
      </li>
    </ul>

    <van-button type="primary" @click="getUserInfo">获取用户信息</van-button>
    <van-button type="primary" @click="login">登录</van-button>

    <!-- 测试图标 -->
    <!-- 1. 默认使用方式=》不推荐 -->
    <!-- <img src="@/icons/home/doctor.svg" /> -->
    <!-- 2. 精灵图 -->
    <svg aria-hidden="true">
      <!-- #icon-文件夹名称-图片名称 -->
      <use href="#icon-home-doctor" />
    </svg>
    <!-- 3. 测试封装的精灵图组件 -->
    <div style="font-size: 18px">
      <cp-icon name="login-eye-on"></cp-icon>
    </div>
  </div>
</template>

<script setup lang="ts">
// import { useUserStore } from '@/stores/modules/user'
// 引入从index全部导出的
import { useUserStore } from '@/stores'
import { ref } from 'vue'
import { request } from '@/utils/request'

import Son from './son.vue'
const show = ref(false)

const store = useUserStore()
const setUser = () => {
  store.setUser({
    id: '123',
    avatar: '',
    account: 'nickname',
    mobile: '13899',
    token: '123'
  })
}
const getUserInfo = async () => {
  const res = await request.get('/patient/myUser')
  console.log(res)
}

const login = async () => {
  const res = await request.post('/login/password', {
    mobile: '13211112222',
    password: 'abc12345'
  })
  store.setUser(res.data)
}

const clickRight = () => {
  console.log('clickRight')
}
</script>
